//
//  CYWithdrawBalanceCell.m
//  cyjf
//
//  Created by tauCross on 2017/5/18.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYWithdrawBalanceCell.h"



@implementation CYWithdrawBalanceCellObject

@end



@interface CYWithdrawBalanceCell ()

@property(nonatomic, strong)UILabel *balanceDescLabel;
@property(nonatomic, strong)UILabel *balanceLabel;
@property(nonatomic, strong)UIImageView *bottomLine;

@end


@implementation CYWithdrawBalanceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.balanceDescLabel = [[UILabel alloc] init];
        self.balanceDescLabel.textColor = HEXCOLOR(@"999999");
        self.balanceDescLabel.font = [UIFont systemFontOfSize:12];
        self.balanceDescLabel.text = @"可用余额(元)";
        [self.balanceDescLabel sizeToFit];
        [self.contentView addSubview:self.balanceDescLabel];
        
        self.balanceLabel = [[UILabel alloc] init];
        self.balanceLabel.textColor = HEXCOLOR(@"444444");
        self.balanceLabel.font = [UIFont systemFontOfSize:38];
        [self.contentView addSubview:self.balanceLabel];
        
        self.bottomLine = [[UIImageView alloc] initWithImage:[UIImage imageWithColor:HEXCOLOR(@"ECECEC") size:CGSizeMake(1, 1)]];
        [self.contentView addSubview:self.bottomLine];
    }
    return self;
}

+ (CGFloat)heightForObject:(id)object atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView
{
    return 100;
}

- (BOOL)shouldUpdateCellWithObject:(CYWithdrawBalanceCellObject *)object
{
    self.balanceLabel.text = object.balance.amountString;
    
    [self setNeedsLayout];
    return YES;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.balanceDescLabel.centerX = self.contentView.width / 2;
    self.balanceDescLabel.centerY = 31;
    
    [self.balanceLabel sizeToFit];
    self.balanceLabel.centerX = self.contentView.width / 2;
    self.balanceLabel.centerY = 61;
    
    self.bottomLine.width = self.contentView.width ;
    self.bottomLine.height = 1 / SCREEN_SCALE;
    self.bottomLine.left = 0;
    self.bottomLine.bottom = self.contentView.height;
}

@end
